import requests
import time

# 1. 设置请求地址和请求头
url = "http://127.0.0.1:5000/api/conversation_stream"

# 请求头参数
headers = {
    "Authorization": "Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJmcmVzaCI6ZmFsc2UsImlhdCI6MTc1MzY4Mzg1MSwianRpIjoiZDFlMTliOTAtNzVhZS00ZWU3LWEwN2EtOWEyMTU2OTdiNjYxIiwidHlwZSI6ImFjY2VzcyIsInN1YiI6ImVhOTI1OTViLTBjMDEtNGI3MS1iMDE3LTI0YWY5NDI3NGMzZiIsIm5iZiI6MTc1MzY4Mzg1MSwiY3NyZiI6IjliNmY4ZjYwLTY2ZmItNGYwMS05YWRjLTJmNTEwYmM2N2Q1ZiIsImV4cCI6MTc1MzY5MTA1MX0.ZyQklfCtYng1_9wVmIjeGtXlE6jhzxPG7VA0GWkRARY",  # 替换为实际 Token
    "Content-Type": "application/json; charset=utf-8"
}

data = {
    "conversation_id": "web_afa9ae91-aa12-4f8a-a9e7-66bd752ab2ab",
    "message": "我要死了。",
    "model_key" : "Qwen/Qwen2.5-VL-72B-Instruct",
}


# 3. 发送 POST 请求，并启用 stream 模式
response = requests.post(url, headers=headers, json=data, stream=True)

# 4. 逐行读取流式响应
try:
    for line in response.iter_lines(decode_unicode=True):
        if line:
            print(line)
except Exception as e:
    print(f"请求出错: {e}")